<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="客户名称" prop="customerName">
        <el-input
          v-model="queryParams.customerName"
          placeholder="请输入客户名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="客户电话" prop="customerTel">
        <el-input
          v-model="queryParams.customerTel"
          placeholder="请输入客户电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="客户星级" prop="level">
        <el-select v-model="queryParams.level" placeholder="请选择星级" clearable>
          <el-option
            v-for="dict in dict.type.level_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="操作时间" prop="operatorDay">
        <el-input
          v-model="queryParams.operatorDay"
          placeholder="请输入操作时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <!--   @selection-change="handleSelectionChange"   -->
    <el-table v-loading="loading" :data="recoverCustomerLogList">
      <!-- <el-table-column type="selection" width="55" align="center" /> -->
      <el-table-column label="客户名称" align="center" prop="customerName" />
      <el-table-column label="客户电话" align="center" prop="customerTel" />
      <el-table-column label="星级" align="center" prop="level">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.level_type" :value="scope.row.level"/>
        </template>
      </el-table-column>
      <el-table-column label="操作时间" align="center" prop="operatorDay" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改客户回收记录对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body v-if="false">
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="客户id" prop="customerId">
          <el-input v-model="form.customerId" placeholder="请输入客户id" />
        </el-form-item>
        <el-form-item label="客户名称" prop="customerName">
          <el-input v-model="form.customerName" placeholder="请输入客户名称" />
        </el-form-item>
        <el-form-item label="客户电话" prop="customerTel">
          <el-input v-model="form.customerTel" placeholder="请输入客户电话" />
        </el-form-item>
        <el-form-item label="客户等级" prop="level">
          <el-input v-model="form.level" placeholder="请输入客户等级" />
        </el-form-item>
        <el-form-item label="操作时间" prop="operatorDay">
          <el-input v-model="form.operatorDay" placeholder="请输入操作时间" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listRecoverCustomerLog } from "@/api/customer/recoverCustomerLog";

export default {
  name: "RecoverCustomerLog",
  data() {
    return {
      // 按钮loading
      buttonLoading: false,
      // 遮罩层
      loading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 客户回收记录表格数据
      recoverCustomerLogList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 100,
        customerId: undefined,
        customerName: undefined,
        customerTel: undefined,
        level: undefined,
        operatorDay: undefined
      },
      // 表单参数
      form: {},
      // 表单校验
    };
  },
  dicts:['level_type'],
  created() {
    this.getList();
  },
  methods: {
    /** 查询客户回收记录列表 */
    getList() {
      this.loading = true;
      listRecoverCustomerLog(this.queryParams).then(response => {
        this.recoverCustomerLogList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        userId: undefined,
        userDept: undefined,
        customerId: undefined,
        customerName: undefined,
        customerTel: undefined,
        level: undefined,
        taskId: undefined,
        createTime: undefined,
        operatorDay: undefined
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
};
</script>
